<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:cs="http://myfaces.apress.com/custom" template="/WEB-INF/layouts/standard.xhtml"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:bf="http://www.bssmanager.com/jsf"
	xmlns:c="http://java.sun.com/jstl/core">


	<ui:define name="headIncludes">
		<style>			
			.rc11 {
				border:0px;
				padding: 0px;
				margin:0px;
			}	
			.rc12 {
				border:0px;
				padding: 0px;
				margin:0px;
				margin-top:2px;
			}	
			
			@media print {
			
			
	
				.rich-page-header { display:none }
				.rich-page-sidebar { display:none }
				.rich-page-footer { display:none} 
				.rich-page-body { margin-left:0;}		
				.rich-page-content {border:0}
				.rich-page-main {border:0}
				.largerFont {
					font-size: 10pt;
				}	
				.largerFont1 {
					font-size: 12pt;
				}	
				.fullBorder {
					border: 2px solid gray;
					/*width:600px;*/
				}	
				.boldfont {
					font-weight: bold;
					font-size: 10pt;
				}
				.boldfont1 {
					font-weight: bold;
					font-size: 12pt;
				}
				.cc {
					margin-bottom: 10px;
				}
			}				
		</style>
	</ui:define>
	

	<ui:define name="content">
		<h:form id="idGenerationController">
			<rich:panel styleClass="noprint" style="border:0;width:100%"  >
									<f:facet name="header">
										<h:outputText styleClass="noprint" value="Select Patient"/>
									</f:facet>
									
				<h:panelGroup >
			<bf:admissionSelector controller="#{idGenerationController}" selectMethod="select" 
								reRender="selectedPatient"/>
								</h:panelGroup>
			
			</rich:panel>
		
			
			<table width="100%">
				<tr>
					<td align="left">
						<h:commandButton value="Refresh" styleClass="noprint" onclick="showLoading();" action="#{idGenerationController.refresh}"/>
					</td>
					<td align="right">
						<h:commandButton value="Print" styleClass="noprint" onclick="window.print();return false;"/>
					</td>
				</tr>
			</table>
			
				
			<table width="100%" class="fullBorder">				
				<tr>
					<td valign="top">
						<h2 align="center" style="text-decoration: underline;">ID CARD</h2>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<h:panelGroup id="selectedPatient">
							<table width="100%" align="left" style="margin-top: 10px;">							
								<tr>
									<td valign="top">
										<table width="100%" align="left" style="text-align: left; table-layout: fixed ">
											<tr>
												<td valign="top" width="45%">
													<h:graphicImage url="/bss/images/saved?id=#{idGenerationController.model.patient.id}"
														alt="not found" width="240" height="180" style="border:thin solid gray;" />
												</td>
												<td valign="top" width="55%">
													<h:panelGrid columns="2">
														<h:outputLabel value="ID: " class="boldfont1"/>
														<h:outputText value="#{idGenerationController.model.id}" class="largerFont1"/>
														<h:outputLabel value="Name:" class="boldfont1"/>
														<h:outputText class="largerFont1"
															value="#{idGenerationController.model.patient.firstName} #{idGenerationController.model.patient.middleName} #{idGenerationController.model.patient.lastName}(#{idGenerationController.model.patient.id})" />
														<h:outputLabel value="Address:" class="boldfont1"/>
														<h:outputText class="largerFont1" value="#{idGenerationController.model.patient.place.name},#{idGenerationController.model.patient.state.name},#{idGenerationController.model.patient.country.name}" />
														<h:outputLabel value="Tata Case Number:" class="boldfont1"/>
														<h:outputText class="largerFont1" value="#{idGenerationController.model.caseNo}" />
														<h:outputLabel value="Stay from: " class="boldfont1"/>
														<h:outputText class="largerFont1" value="#{idGenerationController.model.dateFrom}">
															<f:convertDateTime pattern="dd MMM yyyy" timeZone="#{preferences.timeZone.ID}"/>
														</h:outputText>
														<h:outputLabel value="Stay upto: " class="boldfont1"/>
														<h:outputText class="largerFont1" value="#{idGenerationController.model.dateTo}">
															<f:convertDateTime pattern="dd MMM yyyy" timeZone="#{preferences.timeZone.ID}"/>
														</h:outputText>														
													</h:panelGrid> 
													
													<h:panelGrid columns="1" >
														<f:facet name="header">
															<h:outputLabel value="Attendents" class="boldfont1"/>
														</f:facet>
														<rich:dataList value="#{idGenerationController.model.currentAttendents}" 
																		var="aBean" rowKeyVar="ii" style="line-height:100%" rowClasses="cc" >
															<h:outputText value="#{ii+1})  #{aBean.attendent.name}" class="largerFont1" />
														</rich:dataList>
														<h:outputText rendered="#{empty idGenerationController.model.currentAttendents}" value="No Attendents" />
													</h:panelGrid>
													<h:panelGrid columns="2" class="norender">
														<h:outputLabel value="Security Deposit: " class="boldfont1"/>							
														<h:outputText value="#{idGenerationController.securityDeposit}" class="largerFont1"/>
														<h:outputLabel value="Utensil Deposit: " class="boldfont1"/>							
														<h:outputText value="#{idGenerationController.utensilDeposit}" class="largerFont1"/>
													</h:panelGrid>
												</td>
											</tr>
											<tr>
												<td colspan="2" valign="top" align="left" style="padding-top: 5px;">
													<table>
														<tr>
															<td valign="top" style="border-right: 2px solid gray">
																<h:panelGrid columns="1" rendered="#{not empty idGenerationController.model.roomBookings}">
																	<f:facet name="header">
																		<h:outputLabel value="Rooms" class="boldfont"/>
																	</f:facet>
																	<c:forEach items="#{idGenerationController.model.roomBookings}" var="roomBooking">
																		<h:outputText value="#{roomBooking.room.roomNumber} ( #{roomBooking.room.building.name} )" />
																	</c:forEach>
																	<c:if test="#{empty idGenerationController.model.roomBookings}">
																		<h:outputText value="No Rooms Booked" />
																	</c:if>
																</h:panelGrid> 
																<h:panelGrid columns="1" rendered="#{not empty idGenerationController.model.bedBookings}">
																	<f:facet name="header">
																		<h:outputLabel value="Dormitory Beds: " class="boldfont"/>
																	</f:facet>
																	<c:forEach items="#{idGenerationController.model.bedBookings}" var="bedBooking">
																		<h:outputText
																			value="#{bedBooking.bed.bedNumber} ( #{bedBooking.bed.room.building.name} - #{bedBooking.bed.room.roomNumber} )" />
																	</c:forEach>
																	<c:if test="#{empty idGenerationController.model.bedBookings}">
																		<h:outputText value="No Beds Booked" />
																	</c:if>
																</h:panelGrid>
																<h:panelGrid columns="2" rendered="#{not empty idGenerationController.model.materialSet}">
																	<f:facet name="header">
																		<h:outputLabel value="Utensil Set"  class="boldfont"/>
																	</f:facet>
																	<h:outputText value="#{idGenerationController.model.materialSet}" converter="#{materialSetConverter}" class="largerFont"/>
																																		
																</h:panelGrid>	
															</td>


															<td valign="top" >
																<h:panelGrid columns="4">
																	<f:facet name="header">
																		<h:outputLabel value="Material Set" class="boldfont"/>
																	</f:facet>
																	<c:forEach items="#{idGenerationController.model.materialAllocations}" var="materialAllocation">
																		<h:outputLabel value="#{materialAllocation.materialType.name}" class="largerFont" />
																		<h:outputText value="#{materialAllocation.instances}" 
																			style="width: 15px; margin-right:15px; text-align: center;" class="largerFont"/>
																	</c:forEach>
																</h:panelGrid>
															</td>
															
														</tr>
													</table></td>
											</tr>
										</table></td>
								</tr>

							</table>
						</h:panelGroup></td>
				</tr>
				<tr class="noscreen">
					<td >
						<hr />
					</td>
				</tr>
				<tr class="noscreen">
					<td align="left" valign="top" class="largerFont">Checkout Date</td>
				</tr>
				<tr class="noscreen">
					<td >
						<hr />
					</td>
				</tr>
				<tr class="noscreen">
					<td align="center" valign="top" >
						<h:outputLabel value="Important Guidelines and Instructions"
							style="font-size: 12pt;" />
						<hr /> 						
					</td>
				</tr>
				<tr class="noscreen">
					<td align="left" valign="top" >						
						<rich:dataGrid value="#{guidelinesDao.all}" width="700"
						var="guide" rowKeyVar="ii" columns="1" styleClass="rc11" rowClasses="rc11" columnClasses="rc11" style="border:0px" cellpadding="0" cellspacing="0" >
							<rich:column style="border:0px" styleClass="rc12" >
								<h:outputText value="#{ii+1}) #{guide.description}" class="largerFont" />
							</rich:column>									
						</rich:dataGrid>
					</td>
				</tr>				
				<tr class="noscreen">
					<td >
						<hr />
					</td>
				</tr>
				<tr class="noscreen">
					<td >
						<table cellpadding="0" cellspacing="0" style="table-layout: fixed" width="100%">
							<tr>
								<td style="border-right: 2px solid gray; padding-right: 10px" colspan="50%" align="left" valign="top">
									<div class="largerFont">Received all materials as detailed and ID card</div> 
									<br />
									<br />
									<br />
									<br />
									<br />
									<div>
										<span style="float: right" class="largerFont">Date</span><span style="float: left" class="largerFont">Signature of attendant</span>
									</div>
								</td>
								<td align="left" valign="top" style="padding-left: 10px" colspan="50%">
									<div class="largerFont">Received refund of security deposits</div> 
									<br />
									<br />
									<br />
									<br />
									<br />									
									<div>
										<span style="float: right" class="largerFont">Date</span><span style="float: left" class="largerFont">Signature of attendant</span>
									</div>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			
		</h:form>
				
	</ui:define>
</ui:composition>